package com.mars.nacos.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author : kyrie
 * @date : 2022/8/23 16:34
 * #desc    : 项目API文档配置
 */
@Configuration
@EnableSwagger2
public class APIConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(this.apiInfo())
                .groupName("订单中心API")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mars.nacos.api.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("App Project: 订单中心API服务[order-app-api] Knife API文档")
                .description("order-app-api接口的描述信息")
                .contact(new Contact("kyrie", "18654169290@163.com", "18654169290@163.com"))
                .version("1.0.0")
                .build();
    }
}
